home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / C Internet Config / IC Component Source ƒ / __AppendRoutineDescriptor.r next >
Encoding:
Text File  |  1995-12-06  |  8.0 KB  |  195 lines  |  [TEXT/KAHL]

  1. #include <MixedMode.r>
  2. #include <FatRSRC.r>
  3.  
  4. #define FAT            0
  5. #define SAFE        1
  6. #define SAFER        1
  7. #define CURRENTISA    0
  8. #define SHRINKING    1
  9.  
  10. #define ResType            'PROC'                        //    Change to the type of resource you wish to create
  11. #define ResID            128                            //    Change to the ID of resource you wish to create
  12.  
  13. #if FAT
  14. #define ResName            "IC Component (Fat)"            //    name of our resource
  15. #else
  16. #define ResName            "IC Component (PPC)"            //    name of our resource
  17. #endif
  18.  
  19. #define PPCResFile        "PPC IC Component.π.rsrc"    //    Change to the name of this project's resource file
  20. #define PPCProcInfo        $000003F0                    //    Change to ProcInfo value for your resource's PowerPC code
  21.  
  22. #define M68KResFile        "68K Code"                    //    If FAT, Change to name of the file to merge a 68K resource from
  23. #define M68KResType    'PROC'                        //    If FAT, Change to the type of 68K resource to merge in
  24. #define M68KResID        128                            //    If FAT, Change to the ID of 68K resource to merge in
  25.  
  26. #define M68KProcInfo    $0                            //    Change to ProcInfo value for your fat resource's 68K code
  27.  
  28. /*
  29.     Prepend a routine descriptor (from a 'rdes', 'fdes', 'Fdes', 'sdes', 'Sdes', 'ades', 'Ades' or
  30.     '<des' template) to our temporary resource and store it into a resource with the type and ID
  31.     specified by ResType and ResID.
  32.     
  33.     •    Change the ResType and ResID macros to the resource type and ID you wish to create.
  34.     
  35.     •    Change the PPCResFile macro to the name of this project's resource file.  
  36.  
  37.     •    Change the PPCProcInfo macro to the ProcInfo value for your resource's PowerPC code.  
  38.  
  39.     •    If creating a "Fat" code resource, change the M68KResFile macro to the name of the file to
  40.         merge a 68K resource from.  
  41.  
  42.     •    If creating a "Fat" code resource, change the M68KResType and M68KResID macros to the
  43.         resource type and ID of a 68K resource to merge in.
  44.  
  45.     •    If creating a "Fat" code resource, change the M68KProcInfo macro to the ProcInfo value for
  46.         your 68K code.  
  47.     
  48.     
  49.     Accelerated (native PowerPC) Code Resource ('rdes' template) :
  50.     
  51.     Set FAT to 0 to build an accelerated (native PowerPC) code resource with the 'rdes' template.
  52.     Resources created with this template can be executed on a PowerMac from either PowerPC or
  53.     68K mode.  Calling the resource from 68K code (in emulation) will cause a mode switch.
  54.     Resources created with this template are unusable on 68K Macs.
  55.     
  56.     Fat Code Resource ('fdes' template) :
  57.     
  58.     Set FAT to 1, SAFE to 0, and CURRENTISA to 0 to build a "Fat" code resource with the 'fdes'
  59.     template.  If a resource created with this template is used on a 68K Mac, the 68K portion of the
  60.     code resource will be executed.  If it's used on a PowerMac, the PowerPC portion of the code
  61.     resource will be executed.  You would use this template if, when running on a PowerMac in 68K
  62.     emulation, there is less overhead switching to PowerPC mode and executing your PowerPC code
  63.     than executing your 68K code.  Resources created with this template require the Mixed Mode
  64.     Manager to run on a 68K Mac.
  65.     
  66.     Fat Code Resource dependant on current mode ('Fdes' template) :
  67.     
  68.     Set FAT to 1, SAFE to 0, and CURRENTISA to 1 to build a "Fat" code resource, which is dependant
  69.     on the current mode, with the 'Fdes' template.  Code resources created with this template will
  70.     minimize mode switches by executing your PowerPC code if called by PowerPC code (not in 68K
  71.     emulation), and executing your 68K code if called in emulation (or on a 68K Mac).  You would use
  72.     this template if, when running on a PowerMac in 68K emulation, there is less overhead executing
  73.     your 68K code than switching modes and executing your PowerPC code.  Only use this template if
  74.     your code resource, when running on a PowerMac, might be executed by either 68K or PowerPC
  75.     code.  Resources created with this template require the Mixed Mode Manager to run on a 68K Mac.
  76.     
  77.     Safe Fat Code Resource ('sdes' template) :
  78.     
  79.     Set FAT to 1, SAFE to 1, SAFER to 0, SHRINKING to 0, and CURRENTISA to 0 to build a "Safe
  80.     Fat" code resource with the 'sdes' template.  Code resources created with this template are
  81.     similar to those created by the 'fdes' template (described above), but will run on a 68K Mac
  82.     with or without the Mixed Mode Manager.
  83.     
  84.     Safe Fat Code Resource dependant on current mode ('Sdes' template) :
  85.     
  86.     Set FAT to 1, SAFE to 1, SAFER to 0, SHRINKING to 0, and CURRENTISA to 1 to build a "Safe
  87.     Fat" code resource, which is dependant on the current mode, with the 'Sdes' template.  Code
  88.     resources created with this template are similar to those created with the 'Fdes' template
  89.     (described above), but will run on a 68K Mac with or without the Mixed Mode Manager.
  90.  
  91.     Safer Fat Code Resource ('ades' template) :
  92.     
  93.     Set FAT to 1, SAFE to 1, SAFER to 1, SHRINKING to 0, and CURRENTISA to 0 to build a "Safer
  94.     Fat" code resource with the 'ades' template.  Code resources created with this template are
  95.     similar to those created with the 'sdes' template (described above).  The 'sdes' template was
  96.     inherited from MPW.  We provide a "Safer" code resource template to work around some
  97.     potential problems with the 'sdes' template.  Code resources created with this template support
  98.     register-based calling conventions, and 68K Macs without instruction caches.
  99.     
  100.     Safer Fat Code Resource dependant on current mode ('Ades' template) :
  101.     
  102.     Set FAT to 1, SAFE to 1, SAFER to 1, SHRINKING to 0, and CURRENTISA to 1 to build a "Safer
  103.     Fat" code resource, which is dependant on the current mode, with the 'Ades' template.  Code
  104.     resources created with this template are similar to those created with the 'Sdes' template
  105.     (described above), but works around some potential problems with it.  Code resources created
  106.     with this template supports register-based calling conventions, and 68K Macs without
  107.     instruction caches.
  108.     
  109.     Shrinking Safe Fat Code Resource ('<des' template) :
  110.     
  111.     Set FAT to 1, SAFE to 1, and SHRINKING to 1 to create a "Shrinking Safe Fat" code resource
  112.     with the '<des' template.  You would use this template if, when running on a PowerMac in
  113.     68K emulation, there is less overhead switching to PowerPC mode and executing your
  114.     PowerPC code than executing your 68K code.  This resource will determine what type of Mac
  115.     you are using.  If you are using a 68K Mac, the PowerPC code will be truncated from the end
  116.     of the resource in memory.  If you are using a PowerMac, the PowerPC code will be moved to
  117.     the start of the resource, and the left-over space will be truncated from the end of the
  118.     resource in memory.  This type of resource will run natively to either platform, and will not
  119.     keep unused code in memory.
  120.     
  121.     
  122. !!!    Beware, the 68K register A0 will not point to the start of your resource upon entry.  Some
  123. !!!    68K code resources rely on this.  For example, many INIT's pass A0 to RecoverHandle, to get a
  124. !!!    Handle to their code, to detach it (with DetachResource) from its resource file.  Instead, INIT's
  125. !!!    should use Get1Resource to get this Handle.
  126. !!!
  127. !!!    The SetUpA4-related routines will work properly in the 68K code of a "Fat" resource.
  128.     
  129.     • This file does not set any resource attributes for your code resource.  You must specify your
  130.     resource attributes below (ala Rez), or set them once your resource is built, with ResEdit.
  131.     
  132.     • To create your code resource, simply bring this project up to date.  You do not need to
  133.     generate a target.  Your code resource will be saved to your project's resource file.
  134.  
  135.     • This file must be compiled AFTER "_CopyToResource.r"
  136.     
  137.     Colen Garoutte-Carson
  138.     Symantec Corp.
  139. */
  140.  
  141. #if FAT
  142.     #if SAFE
  143.         #if SHRINKING
  144.             type ResType as '<des';
  145.         #else
  146.             #if SAFER
  147.                 #if CURRENTISA
  148.                     type ResType as 'Ades';
  149.                 #else
  150.                     type ResType as 'ades';
  151.                 #endif
  152.             #else
  153.                 #if CURRENTISA
  154.                     type ResType as 'Sdes';
  155.                 #else
  156.                     type ResType as 'sdes';
  157.                 #endif
  158.             #endif    
  159.         #endif
  160.     #else
  161.         #if CURRENTISA
  162.             type ResType as 'Fdes';
  163.         #else
  164.             type ResType as 'fdes';
  165.         #endif
  166.     #endif
  167. #else
  168.     type ResType as 'rdes';
  169. #endif
  170.  
  171. resource ResType (ResID,ResName) {
  172. #if FAT
  173.     #if SAFE
  174.         #if !SHRINKING
  175.             M68KProcInfo,
  176.             PPCProcInfo,
  177.         #endif
  178.     #else
  179.         M68KProcInfo,
  180.         PPCProcInfo,
  181.     #endif
  182. #else    
  183.     PPCProcInfo,
  184. #endif
  185. #if FAT
  186.     $$Resource(M68KResFile, M68KResType, M68KResID),
  187.     #if SAFE
  188.         #if SHRINKING
  189.             PPCProcInfo,
  190.         #endif
  191.     #endif
  192. #endif
  193.     $$Resource(PPCResFile, 'TEMP', 0)
  194. };
  195.